
package game;

import org.newdawn.slick.BasicGame;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;

import game.resources.InputManager;
import game.resources.TikalPlayer;
import game.structures.Camera;
import game.structures.Layer;
import game.structures.Player;
import game.structures.Point;



public class Main extends BasicGame {

	Player player = new TikalPlayer(new Point(300f, 300f));
	Layer layer = new Layer();
	Camera camera = new Camera(player, layer);
	
	float rot	 = 0.0f;
	InputManager input = InputManager.getInstance();
	
	public Main()
	{
		super("Tikal is awesome");
	}
	
	public void init(GameContainer gc) throws SlickException {
		InputManager.getInstance().setGameContainer(gc);
		player.init();
		layer.init();
		
		player.setLayer(layer);
		
		update(gc, 0);
		
		gc.setTargetFrameRate(60);     
	}
	
	public void update(GameContainer gc, int delta) throws SlickException { 
		input.update();

		layer.update(delta);
		camera.update(delta);
		player.update(delta);
		
		rot = (rot + 0.1f*delta) % 360f;
	}
	
	public void render(GameContainer gc, Graphics g) throws SlickException {
		layer.draw(camera);
		player.draw(camera);
	}
	
	public static void main(String[] args) throws SlickException {
		AppGameContainer app = new AppGameContainer(new Main());
		
		app.setDisplayMode(800, 600, false);
		app.start();
	}
}
